package com.xhdd.serv;

import co.elastic.clients.elasticsearch.indices.IndexState;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.xhdd.dto.CodeData;
import com.xhdd.dto.MetaData;
import com.xhdd.util.global.AdjoinCode;
import com.xhdd.util.global.Cell;
import com.xhdd.util.global.Params;
import org.locationtech.jts.io.ParseException;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface CodeService {
    //插入元数据并初始化数据表

    Boolean indexDelete(String indexName) throws IOException;

    Map<String, IndexState> listIndex() throws IOException;


    ArrayNode searchDoc(String indexName, List<Params> params, Integer page, Integer size) throws IOException;

    ArrayNode searchPrefix(String indexName, List<String> prefixs, Integer page, Integer size) throws IOException;

    ArrayNode search(String indexName, List<String> prefixs, List<Params> params, Integer page, Integer size) throws IOException;

    String insertDoc(String indexName, String id, JsonNode doc) throws IOException, ParseException;

    String code(CodeData data) throws IOException, ParseException;


    Map<String, Double> propAggs(String indexName, String prop) throws IOException;

    /*去重统计在非分词类型上结果准确*/
    long noRepeatCount(String indexName, String prop) throws IOException;

    /*分组，热力图*/
    HashMap<String, Long> groupBy(String indexName, List<Params> params, String prop, String propType) throws IOException;

    List<Cell> codes2Dj(List<String> codes);

    double getStep(Integer level);

    AdjoinCode get4adjoin(String code);

    void dealFile(String in, String indexName) throws Exception ;

    Boolean initMetaTbDoc(MetaData data) throws IOException;
}
